<template>
	<view class="content">
		<navbar title='核销管理'>
		</navbar>
		<view class="content">
			<view class="nlist">
				<view class="nitem" v-for="(item,index) in list" :key="index" @click.stop="gethexiao(item)">
					<view class="sview">
						<text class="syname">{{ '收银员'+index+1+'号' }}</text>
						<text class="delclass" @click.stop="del(item)">删除收银员</text>
					</view>
					<view class="nione">
						<image class="tous" :src="item.avatar" />
						<view class="niright">
							<view class="rione">
								<text class="riname txt">{{item.name}}</text>
								<!-- <text class="hyuan">会员</text> -->
							</view>
							<view class="rione mttwo">
								<text class="idname hui">注册时间：{{item.createtime}}</text>
							</view>
						</view>
						<view class="ehji">
							<text class="hetit">核销记录</text>
							<image class="comm_icon_next" src="@/pages_client/static/img/comm_icon_next.png" />
						</view>
						
					</view>
					<view class="zheview">
						<view class="zheitem">
							<view class="items">
								<text class="ileft">核销次数:</text>
								<text class="ival">{{ item.hexiao_nums }}</text>
							</view>
							<view class="items">
								<text class="ileft">核销金额(元):</text>
								<text class="ival">{{item.hexiao_money}}元</text>
							</view>
						</view>
					</view>
				</view>
				
			</view>
		</view>

		<view class="botview">
			<view class="tjia" @click="getadd">添加收银员</view>
			<!-- <view class="lihe ml">立即核销</view> -->
		</view>

		<!-- 添加收银员 -->
		<u-popup  v-model="sypopshow" mode="bottom" width="100%" ref="auth" :closeable="true" :mask-close-able="false" :custom="true" :mask-click="false" @close="closesy">
            <view class="popone">
                <text class="xuantit">
                    添加收银员
                </text>
                <view class="addtuan">
                    <view class="aditem">
                        <text class="addname">收银员名称</text>
                        <u-input v-model="name" type="text" placeholder='请输入收银员名称' />
                    </view>
                    <view class="aditem">
                        <text class="addname">手机号</text>
                        <u-input v-model="mobile" type="text" placeholder='请输入手机号' />
                    </view>
                </view>
                <view class="menbot">
                    <view class="mbots" @click="getxuanmen">确认添加</view>
                </view>
            </view>
        </u-popup>
	</view>
</template>

<script>
	export default {
		components: {
		},
		data() {
			return {
				sypopshow:false,
				name:"",
				mobile:'',
				shop_id:'',
				list: [],
				page: 1,
				limit: 10,
				last_page: 1,
				status: "loadmore",

			}
		},
		onLoad(option) {
			if(option.shop_id){
				this.shop_id = option.shop_id
			}
			this.getList()
		},
		onShow() {
		},
		methods: {
			closesy(){
				this.sypopshow = false
				this.name = ''
				this.mobile = ''
			},
			getadd(){
				this.sypopshow = true
			},
			getyueji(){
				this.navrouter("/pages_client/twoPage/MyTeamYueji");
			},
			async getList(){//列表数据
				let res = await this.$u.api.getAdmin({
				  shop_id:this.shop_id
				});
				// this.last_page = res.lastpage
				this.list = res;
				// this.list = this.page == 1 ? list : [...this.list, ...list];	
				// if(res.list==''||Number(list.length)<Number(this.limit)||Number(this.page)>Number(this.last_page)){
				// 	this.status = 'nomore';
				// }
			},
			async getxuanmen(){
				if(!this.name){
					this.$u.toast("请输入姓名");
					return;
				}
				if(!this.mobile){
					this.$u.toast("请输入手机号");
					return;
				}
				let res = await this.$u.api.addAdmin({
				  shop_id:this.shop_id,
				  name:this.name,
				  mobile:this.mobile,
				});
				this.$u.toast("添加成功");
				this.getList()
				this.closesy()
			},
			gethexiao(item){
				this.navrouter("/pages_client/twoPage/HXRecord?shop_id="+this.shop_id+'&user_id='+item.user_id);
			},
			async del(item){
					//退出登陆
					let that = this
					uni.showModal({
						title: '提示',
						content: '确定删除？',
						cancelText: "取消", // 取消按钮的文字  
						confirmText: "确认", // 确认按钮的文字  
						// showCancel: false, // 是否显示取消按钮，默认为 true
						// confirmColor: '#f55850',
						// cancelColor: '#39B54A',
						success: (res) => {
						if(res.confirm) {  
							that.deltwo(item)
						} else {  
							console.log('cancel') //点击取消之后执行的代码
							}  
						} 
					})
				},
				async deltwo(item){
					let res = await this.$u.api.sdelAdmin({
						id:item.id,
						shop_id:this.shop_id
					});
					this.$u.toast("操作成功");
					this.getList()
				},
			// 
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #f9f9f9;
	}
	.content{
		background-color: #f9f9f9;
		padding-bottom: 130rpx;
		min-height: 100vh;
		.tuanone{
			background-color: #fff;
			padding: 15rpx 30rpx;
			display: flex;
			flex-direction: row;
			align-items: center;
			.tuhead{
				max-width: 80%;
				white-space: nowrap;
				.tuitem{
					padding: 8rpx 20rpx;
					background: #F5F5F5;
					border-radius: 10rpx;
					margin-right: 20rpx;
					font-weight: 500;
					font-size: 26rpx;
					color: #333333;
					display: inline-block;
				}
				.tactive{
					background: #52443B;
					color: #fff;
				}
			}
			.icon_tx{
				margin-left: auto;
				width: 40rpx;
				height: 40rpx;
			}
		}	
	}
	.nlist{
		padding: 20rpx;
		display: flex;
		flex-direction: column;
		.nitem{
			padding: 20rpx 25rpx;
			background: #FFFFFF;
			border-radius: 30rpx;
			.syname{
				font-weight: bold;
				font-size: 32rpx;
				color: #1A1A1A;
				display: block;
				
			}
			.nione{
				display: flex;
				flex-direction: row;
				align-items: center;
				.tous{
					width: 81rpx;
					border-radius: 50%;
					height: 81rpx;
					margin-right: 15rpx;
				}
				.niright{
					width: 65%;
					display: flex;
					flex-direction: column;
					.rione{
						display: flex;
						flex-direction: row;
						align-items: center;
						.riname{
							max-width: 80%;
							display: inline-block;
							font-weight: bold;
							font-size: 32rpx;
							color: #333333;
						}
						.hyuan{
							// width: 80rpx;
							// height: 32rpx;
							padding: 4rpx 20rpx;
							background: linear-gradient(-90deg, #272727, #4D4D4D);
							border-radius: 6rpx;
							display: flex;
							align-items: center;
							justify-content: center;
							font-weight: 500;
							font-size: 22rpx;
							color: #FFFFFF;
							margin-left: 10rpx;
						}
						.idname{
							font-weight: 400;
							font-size: 24rpx;
							color: #999999;
						}
						.hui{
							// margin-left: 40rpx;
						}

					}
					.mttwo{
						margin-top: 15rpx;
					}
				}
				.ehji{
					margin-left: auto;
					display: flex;
					flex-direction: row;
					align-items: center;
					.hetit{
						font-weight: 400;
						font-size: 24rpx;
						color: #999999;
					}
				}
				.comm_icon_next{
					margin-left: 10rpx;
					width: 24rpx;
					height: 24rpx;
				}
			}
			.zheview{
				border-top: 1rpx solid #eee;
				display: flex;
				flex-direction: column;
				margin-top: 20rpx;
				padding-top: 20rpx;
				.zheitem{
					display: flex;
					flex-direction: row;
					flex-wrap: wrap;
					.items{
						width: 50%;
						display: flex;
						flex-direction: row;
						align-items: center;
						margin-bottom: 10rpx;
						.ileft{
							font-weight: 500;
							font-size: 24rpx;
							color: #999999;
						}
						.ival{
							font-weight: 500;
							font-size: 26rpx;
							color: #333333;
						}
					}
				}
				.shengbtn{
					display: flex;
					flex-direction: row;
					justify-content: flex-end;
					padding: 0 20rpx 20rpx 0;
					.sbtn{
						padding: 15rpx 25rpx;
						background: #52443B;
						border-radius: 16rpx 16rpx 16rpx 16rpx;
						font-weight: bold;
						font-size: 28rpx;
						color: #FFFFFF;
						margin-left: 20rpx;
					}
				}
			}
		}
	}
	.botview{
		position: fixed;
		height: 120rpx;
		width: 100%;
		bottom: 0;
		background-color: #fff;
		z-index: 10;
		padding: 0 30rpx;
		display: flex;
		align-items: center;
		.tjia{
			width: 100%;
			height: 90rpx;
			background: #52443B;
			border-radius: 16rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-weight: bold;
			font-size: 28rpx;
			color: #FFFFFF;
		}
		.lihe{
			width: 48%;
			height: 90rpx;
			background: #FF7B2C;
			border-radius: 16rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-weight: bold;
			font-size: 28rpx;
			color: #FFFFFF;
		}
	}

	.popone{
        width: 100%;
        // padding: 30rpx;
        background: #F5F5F5;
        border-radius: 20rpx 20rpx 0rpx 0rpx;
        .addtuan{
            display: flex;
            flex-direction: column;
            padding: 0 30rpx;
            .aditem{
                background: #FFFFFF;
                border-radius: 20rpx;
                padding: 10rpx 30rpx;
                display: flex;
                flex-direction: row;
                align-items: center;
                margin-bottom: 25rpx;
                min-height: 100rpx;

                .addname{
                    font-weight: bold;
                    font-size: 28rpx;
                    color: #333333;
                    display: inline-block;
                    width: 150rpx;
                }
                .comm_icon_next{
                    width: 24rpx;
                    height: 24rpx;
                    margin-left: auto;
                }
            }
        }
        .xuantit{
            font-weight: bold;
            font-size: 32rpx;
            color: #222222;
            display: block;
            text-align: center;
            padding: 30rpx 30rpx 40rpx;
        }
	}
	.menbot{
        height: 110rpx;
        background: #FFFFFF;
        display: flex;
        flex-direction: row;
        align-items: center;
        .mbots{
            height: 90rpx;
            background: #52443B;
            border-radius: 16rpx;
            width: 94%;
            margin: 0 auto;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 500;
            font-size: 28rpx;
            color: #FFFFFF;
        }
    }
	.sview{
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-bottom: 20rpx;
		.delclass{
			margin-left: auto;
			color: red;
			font-size: 24rpx;
			font-weight: normal;
		}
	}
</style>
